package com.weiyi.mashangzhu.Landlord.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.weiyi.mashangzhu.Landlord.Bean.DiscountBean;
import com.weiyi.mashangzhu.R;

import java.util.List;

/**
 * Created by win7 on 2017/9/25.
 */

public class DiscountAdapter extends BaseAdapter {
    List<DiscountBean> list;
    Context context;

    public DiscountAdapter(List<DiscountBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_discount, null);
            viewHolder.title = (TextView) convertView.findViewById(R.id.title);
            viewHolder.count = (TextView) convertView.findViewById(R.id.count);
            convertView.setTag(viewHolder);

        }
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.count.setText(list.get(position).getCount());
        viewHolder.title.setText(list.get(position).getTitle());
        return convertView;
    }

    class ViewHolder {
        TextView title,count;
    }
}
